<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script src="./js/jquery-1.9.1.js"></script>
<script src="./ibsheet/ibsheetinfo.js"></script>
<script src="./ibsheet/ibsheet.js"></script>
<script>
	$(document).ready(function() {
		//sheet 초기화  
		createIBSheet2(document.getElementById("viewArea"),"mySheet","100%","400px");
		
		var sheet_init = {};
		sheet_init.Cfg = {FrozenCol:0,SearchMode:smLazyLoad,Page:30};
		
		//HeaderMode
		sheet_init.HeaderMode = {Sort:1,ColMove:1,ColResize:1,HeaderCheck:0};
		sheet_init.Cols = [
		       			{Header:"NO",		Type:"Seq", Align:"Right"},
		       			{Header:"상태",		Type:"Status", Align:"Center"},
		       			{Header:"삭제",		Type:"DelCheck"},
		       			{Header:"문자열",		Type:"Html", KeyField:1, Align:"Center"},
		       			{Header:"콤보",		Type:"Combo", Width:80, ComboText:"대기|진행중|완료", ComboCode:"01|02|03",PopupText:"대기|진행중|완료"},
		       			{Header:"콤보에디트",	Type:"Html", Width:80},
		       			{Header:"팝업",		Type:"Popup", Width:100},
		       			{Header:"팝업에디트",	Type:"PopupEdit", Width:100},
		       			{Header:"자동합계",	Type:"AutoSum", Align:"Right",Width:70,Format:"NullInteger"},
		       			{Header:"자동평균",	Type:"AutoAvg", Align:"Right",Width:70, Format:"NullFloat"},
		       			{Header:"정수",		Type:"Int", Align:"Right", Format:"Integer",Width:70, Hidden:1},
		       			{Header:"실수",		Type:"Float", Align:"Right", Format:"Float",Width:70, Hidden:1},
		       			{Header:"날짜",		Type:"Date", Align:"Center", Format:"Ymd", Width:100},
		       			{Header:"패스워드",	Type:"Pass", Hidden:1},
		       			{Header:"체크박스",	Type:"CheckBox"},
		       			{Header:"라디오",	Type:"Radio"}
		       		];
		
		IBS_InitSheet(mySheet, sheet_init);
	
		//컬럼의 너비 조정
		mySheet.FitColWidth();
		
		mySheet.SetComboOpenMode(1);

		doAction("search");
	});
	
	function mySheet_OnMouseDown(Button, Shift, X, Y) {
		$('#rowIdx').val(mySheet.MouseRow());
	}
	
	function setCellValue() {
		var row = parseInt($('#rowIdx').val());
		var tag = $('#htmlTag').val();
		
		mySheet.SetCellText(row, 3, tag);
	}

	/*Sheet 각종 처리*/
	function doAction(sAction) {
		
		switch(sAction) {
			case "search":		//조회
				mySheet.DoSearch("./data/sheet_data.xml");
				break;
				
			case "init":		//초기화
				mySheet.Reset();
				createSheet();
				break;
		}
	}
	
	function mySheet_OnSearchEnd(code, message) {
		var data = "<html>";
			data += "<select id='combo'>";
			data += "<option value='-2'>-2</option>";
			data += "<option value='-1'>-1</option>";
			data += "<option value='0'>0</option>";
			data += "<option value='1'>1</option>";
			data += "<option value='2'>2</option>";
			data += "</select>";
			data += "</html>";
		
		var count = mySheet.RowCount() + 1;
		
		for ( var i = 1; i < count; i++) {
			mySheet.SetCellValue(i, 5, data);
		}
			
	}
	
</script>
<title>HTML 컬럼 사용</title>
</head>
<body>
<div id="main">
	<div id="title">HTML 컬럼 사용</div>
	<div align="right">
		<input type="button" value="초기화" onclick="doAction('init')">
		<input type="button" value="조회" onclick="doAction('search')">
	</div>
	<div id="viewArea">
	</div>
</div>
</body>
</html>